<?php


namespace app\model\admin;


use think\Model;
use think\model\concern\SoftDelete;

class AdminUserModel extends Model
{
    use SoftDelete;
    protected $defaultSoftDelete = 0;

    protected $name = 'admin_user';
    protected $autoWriteTimestamp = true;

    protected $hidden = ['password', 'update_time', 'delete_time'];

    public function role()
    {
        return $this->hasOne(AdminRoleModel::class, 'id', 'role_id')->bind(['role_name']);
    }

    public function setPasswordAttr($value)
    {
        if ($value == '') {
            return false;
        }
        return password_hash($value, PASSWORD_DEFAULT);
    }
}